﻿
<style>
    #divDeptTree {
        margin-top: 20px;
        margin-left: 20px;
        margin-bottom: 100px;
    }

    .layui-tree-entry {
        margin-bottom: 5px !important;
    }
</style>


<div id="divDeptTree"></div>


<script>
    var DeptTree = function () {
        let inited = false;
        let data = {};
        var table;

        function initData() {
            layui.use(['tree', 'element'], function () {

                //加载数据
                loadData();

                var treeData = [];
                $.ajax({
                    url: "/Dept/GetDeptTree",
                    type: "GET",
                    success: function (data) {
                        treeData = data;

                        //基本演示
                        layui.tree.render({
                            elem: '#divDeptTree'
                            , data: treeData
                            //, showCheckbox: true  //是否显示复选框
                            //, id: 'demoId1'
                            , isJump: true //是否允许点击节点时弹出新窗口跳转
                            , click: function (obj) {
                                //var data = obj.data;  //获取当前点击的节点数据
                                //layer.msg('状态：' + obj.state + '<br>节点数据：' + JSON.stringify(data));
                            }
                            //, showLine: false
                            //, onlyIconControl: true
                        });
                    }
                });
            });

        }

        function loadData() {
        }

        return {
            init() {//初始化
                if (!inited) {
                    initData();
                    inited = true;
                }
            }
        };
    }();
</script>

